package com.heima.model.behavior.pojos;

import lombok.Builder;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.Date;

/**
 * APP收藏信息表
 *
 * @author itheima
 */
@Data
@Builder
@Document("ap_collection")
public class ApCollection implements Serializable {
    private static final long serialVersionUID = 1L;
    private String id;
    /**
     * 实体ID
     */
    private String entryId;
    /**
     * 文章ID
     */
    private Long articleId;
    /**
     * 收藏内容类型
     * 0文章
     * 1动态
     */
    private Short type;
    /**
     * 操作类型
     * 0收藏
     * 1取消收藏
     */
    private Short Operation;
    /**
     * 创建时间
     */
    private Date collectionTime;

    public boolean isCollectionArticle() {
        return (this.getType() != null && this.getType().equals(Type.ARTICLE));
    }

    public enum Type {
        ARTICLE((short) 0), DYNAMIC((short) 1);
        short code;

        Type(short code) {
            this.code = code;
        }

        public short getCode() {
            return this.code;
        }
    }

    public enum Operation {
        COLLECT((short) 0), CANCEL((short) 1);
        short code;

        Operation(short code) {
            this.code = code;
        }


        public short getCode() {
            return this.code;
        }
    }
}